package autocode

import (
	"github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
    autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/service"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type BusNovelsListApi struct {
}

var busNovelsListService = service.ServiceGroupApp.AutoCodeServiceGroup.BusNovelsListService


// CreateBusNovelsList 创建BusNovelsList
// @Tags BusNovelsList
// @Summary 创建BusNovelsList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.BusNovelsList true "创建BusNovelsList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /busNovelsList/createBusNovelsList [post]
func (busNovelsListApi *BusNovelsListApi) CreateBusNovelsList(c *gin.Context) {
	var busNovelsList autocode.BusNovelsList
	_ = c.ShouldBindJSON(&busNovelsList)
	if err := busNovelsListService.CreateBusNovelsList(busNovelsList); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// DeleteBusNovelsList 删除BusNovelsList
// @Tags BusNovelsList
// @Summary 删除BusNovelsList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.BusNovelsList true "删除BusNovelsList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /busNovelsList/deleteBusNovelsList [delete]
func (busNovelsListApi *BusNovelsListApi) DeleteBusNovelsList(c *gin.Context) {
	var busNovelsList autocode.BusNovelsList
	_ = c.ShouldBindJSON(&busNovelsList)
	if err := busNovelsListService.DeleteBusNovelsList(busNovelsList); err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败", c)
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

// DeleteBusNovelsListByIds 批量删除BusNovelsList
// @Tags BusNovelsList
// @Summary 批量删除BusNovelsList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除BusNovelsList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /busNovelsList/deleteBusNovelsListByIds [delete]
func (busNovelsListApi *BusNovelsListApi) DeleteBusNovelsListByIds(c *gin.Context) {
	var IDS request.IdsReq
    _ = c.ShouldBindJSON(&IDS)
	if err := busNovelsListService.DeleteBusNovelsListByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}

// UpdateBusNovelsList 更新BusNovelsList
// @Tags BusNovelsList
// @Summary 更新BusNovelsList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.BusNovelsList true "更新BusNovelsList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /busNovelsList/updateBusNovelsList [put]
func (busNovelsListApi *BusNovelsListApi) UpdateBusNovelsList(c *gin.Context) {
	var busNovelsList autocode.BusNovelsList
	_ = c.ShouldBindJSON(&busNovelsList)
	if err := busNovelsListService.UpdateBusNovelsList(busNovelsList); err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败", c)
	} else {
		response.OkWithMessage("更新成功", c)
	}
}

// FindBusNovelsList 用id查询BusNovelsList
// @Tags BusNovelsList
// @Summary 用id查询BusNovelsList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query autocode.BusNovelsList true "用id查询BusNovelsList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /busNovelsList/findBusNovelsList [get]
func (busNovelsListApi *BusNovelsListApi) FindBusNovelsList(c *gin.Context) {
	var busNovelsList autocode.BusNovelsList
	_ = c.ShouldBindQuery(&busNovelsList)
	if err, rebusNovelsList := busNovelsListService.GetBusNovelsList(busNovelsList.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"rebusNovelsList": rebusNovelsList}, c)
	}
}

// GetBusNovelsListList 分页获取BusNovelsList列表
// @Tags BusNovelsList
// @Summary 分页获取BusNovelsList列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query autocodeReq.BusNovelsListSearch true "分页获取BusNovelsList列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /busNovelsList/getBusNovelsListList [get]
func (busNovelsListApi *BusNovelsListApi) GetBusNovelsListList(c *gin.Context) {
	var pageInfo autocodeReq.BusNovelsListSearch
	_ = c.ShouldBindQuery(&pageInfo)
	if err, list, total := busNovelsListService.GetBusNovelsListInfoList(pageInfo); err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败", c)
    } else {
        response.OkWithDetailed(response.PageResult{
            List:     list,
            Total:    total,
            Page:     pageInfo.Page,
            PageSize: pageInfo.PageSize,
        }, "获取成功", c)
    }
}




func (busNovelsListApi *BusNovelsListApi)  CreateBusNovelsListByObject(name string , uuid string) autocode.BusNovelsList{
	s := autocode.BusNovelsList{
        Name:   name,
		Uuid:   uuid,
    }
	return s
}


func (busNovelsListApi *BusNovelsListApi) DeleteAllBusNovelsList() {
	busNovelsListService.DeleteAllBusNovelsList()
}